package top.huhuiyu.springboot3.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;
import top.huhuiyu.springboot3.base.R;

/**
 * 自定义异常
 *
 * @author 胡辉煜
 */
@EqualsAndHashCode(callSuper = false)
@Data
public class AppException extends RuntimeException {
  private int code = R.ERROR;
  private String token;

  public AppException(String message) {
    super(message);
  }

  public AppException(int code, String message) {
    super(message);
    this.code = code;
  }

  public static AppException getInstance(String message) {
    return AppException.getInstance(R.ERROR, message);
  }

  public static AppException getInstance(int code, String message) {
    return new AppException(code, message);
  }
}
